<template>
<div style="position: relative;text-align: center;margin: 0 auto;width: 80%;">
    <table class="hideInTable" cellspacing="0" border="1">
        <tr><!-- 顶部title -->
            <th>类型</th><th>项目</th><th>分值</th><th>内容</th><th>得分</th>
        </tr>
        <tr v-if="!tableInfo"><!-- 暂无数据时显示 -->
            <td :colspan="6">暂无数据</td>
        </tr>
        <!-- template不会被渲染 -->
        <template v-for="(item,index) in tableInfo">
            <!-- 左侧跨行区域 -->
            <tr>
                <!-- <td :rowspan="31">{{item.type}}</td> -->
                <td :rowspan="sumProject(item.project)">{{item.type}}</td>
            </tr>
            <!-- 右侧数据 -->
            <template v-for="(project,index2) in item.project">
                <tr :key="project.id">
                    <td :rowspan="project.data.length+1">{{project.name}}</td>
                    <td :rowspan="project.data.length+1">{{project.scoreLimit}}</td>
                </tr>
                <tr v-for="(data,index3) in project.data" :key="data.id">
                    <td class="content">{{data.content}}</td>
                    <td>
                        
                        <el-input v-model="data.score" class="myINput" :disabled="disabledEdit" v-show="data.type=='input'" style="width:80%"></el-input>
                        <el-select v-model="data.iSok" placeholder="请选择" class="myINput"  v-show="data.type=='select'" :disabled="disabledEdit">
                            <el-option v-for="item in oks" :key="item.value" :label="item.label" :value="item.value" ></el-option>
                        </el-select>
                        <el-button type="text" :disabled="data.reason==''" @click="showreason(data)" >原因</el-button>
                    </td>
                </tr>
            </template>
        </template>
    </table>
    <el-button type="text" v-if="!disabledEdit" @click="update" >提交修改</el-button>
    </div>
</template>
<script>

    export default {
        components:{
        },
        data() {
            return {
                disabledEdit:false, //是否可以编辑
                personID:'',
                year:2015,
                createNew:true,
                oks: [{
                    value: '合格',
                    label: '合格'
                    }, {
                    value: '不合格',
                    label: '不合格',
                    disabled: true
                }],
                tableInfo: [],// 数据格式
                points:{
                    subpoint:{
                        p11:{
                            point:0,
                            reason:''
                        },
                        p12:{
                            point:0,
                            reason:''
                        },
                        p13:{
                            point:0,
                            reason:''
                        },
                        p14:{
                            point:0,
                            reason:''
                        },
                        p21:{
                            point:0,
                            reason:''
                        },
                        p22:{
                            point:0,
                            reason:''
                        },
                        p23:{
                            point:0,
                            reason:''
                        },
                        p24:{
                            point:0,
                            reason:''
                        },
                        p25:{
                            point:0,
                            reason:''
                        },
                        p26:{
                            point:20,
                            reason:''
                        },
                        p31:{
                            point:0,
                            reason:''
                        },
                        p32:{
                            point:0,
                            reason:''
                        },
                        p33:{
                            point:0,
                            reason:''
                        },
                        p34:{
                            point:0,
                            reason:''
                        },
                        p35:{
                            point:0,
                            reason:''
                        },
                        p41:{
                            point:0,
                            reason:''
                        },
                        p42:{
                            point:0,
                            reason:''
                        },
                        p43:{
                            point:0,
                            reason:''
                        },
                        p44:{
                            point:0,
                            reason:''
                        },
                        p51:{
                            point:0,
                            reason:''
                        },
                        p52:{
                            point:0,
                            reason:''
                        },
                        p53:{
                            point:0,
                            reason:''
                        },
                        p54:{
                            point:0,
                            reason:''
                        },
                        p55:{
                            point:0,
                            reason:''
                        },
                        p56:{
                            point:0,
                            reason:''
                        }
                    },
                    addpoint:{ //加分项
                        p61:{
                            point:0,
                            reason:''
                        },
                        p62:{
                            point:0,
                            reason:''
                        },
                        p63:{
                            point:0,
                            reason:''
                        },
                        p64:{
                            point:0,
                            reason:''
                        },
                        p65:{
                            point:0,
                            reason:''
                        },
                        p66:{
                            point:0,
                            reason:''
                        },
                        p67:{
                            point:0,
                            reason:''
                        }
                    },
                    foujue:{//一票否决
                        p71:{
                            iSok:'合格',
                            reason:''
                        }, ///加分项
                        p72:{
                            iSok:'合格',
                            reason:''
                        },
                        p73:{
                            iSok:'合格',
                            reason:''
                        },
                        p74:{
                            iSok:'合格',
                            reason:''
                        },
                        p75:{
                            iSok:'合格',
                            reason:''
                        },
                        p76:{
                            iSok:'合格',
                            reason:''
                        },
                    },
                    PointCout:{
                        p81:{   //p11---p81  100-
                            point:0
                        },
                        p82:{
                            point:0
                        },
                        p83:{
                            pointIn:0,
                            point:0
                        },
                        p84:{
                            point:0
                        },
                        p85:{
                            point:0
                        }
                    }
                },
            };
        },
        mounted(){
            this.GetPoint();
            this.FztableInfo();
        },
         watch: {
            "tableInfo":{
				handler(){
                    this.points.subpoint.p11.point=this.tableInfo[0].project[0].data[0].score;this.points.subpoint.p11.reason=this.tableInfo[0].project[0].data[0].reason;
                    this.points.subpoint.p12.point=this.tableInfo[0].project[0].data[1].score;this.points.subpoint.p12.reason=this.tableInfo[0].project[0].data[1].reason;
                    this.points.subpoint.p13.point=this.tableInfo[0].project[0].data[2].score;this.points.subpoint.p13.reason=this.tableInfo[0].project[0].data[2].reason;
                    this.points.subpoint.p14.point=this.tableInfo[0].project[0].data[3].score;this.points.subpoint.p14.reason=this.tableInfo[0].project[0].data[3].reason;

                    this.points.subpoint.p21.point=this.tableInfo[0].project[1].data[0].score;this.points.subpoint.p21.reason=this.tableInfo[0].project[1].data[0].reason;
                    this.points.subpoint.p22.point=this.tableInfo[0].project[1].data[1].score;this.points.subpoint.p22.reason=this.tableInfo[0].project[1].data[1].reason;
                    this.points.subpoint.p23.point=this.tableInfo[0].project[1].data[2].score;this.points.subpoint.p23.reason=this.tableInfo[0].project[1].data[2].reason;
                    this.points.subpoint.p24.point=this.tableInfo[0].project[1].data[3].score;this.points.subpoint.p24.reason=this.tableInfo[0].project[1].data[3].reason;
                    this.points.subpoint.p25.point=this.tableInfo[0].project[1].data[4].score;this.points.subpoint.p25.reason=this.tableInfo[0].project[1].data[4].reason;
                    this.points.subpoint.p26.point=this.tableInfo[0].project[1].data[5].score;this.points.subpoint.p26.reason=this.tableInfo[0].project[1].data[5].reason;

                    this.points.subpoint.p31.point=this.tableInfo[0].project[2].data[0].score;this.points.subpoint.p31.reason=this.tableInfo[0].project[2].data[0].reason;
                    this.points.subpoint.p32.point=this.tableInfo[0].project[2].data[1].score;this.points.subpoint.p32.reason=this.tableInfo[0].project[2].data[1].reason;
                    this.points.subpoint.p33.point=this.tableInfo[0].project[2].data[2].score;this.points.subpoint.p33.reason=this.tableInfo[0].project[2].data[2].reason;
                    this.points.subpoint.p34.point=this.tableInfo[0].project[2].data[3].score;this.points.subpoint.p34.reason=this.tableInfo[0].project[2].data[3].reason;
                    this.points.subpoint.p35.point=this.tableInfo[0].project[2].data[4].score;this.points.subpoint.p35.reason=this.tableInfo[0].project[2].data[4].reason;

                    this.points.subpoint.p41.point=this.tableInfo[0].project[3].data[0].score;this.points.subpoint.p41.reason=this.tableInfo[0].project[3].data[0].reason;
                    this.points.subpoint.p42.point=this.tableInfo[0].project[3].data[1].score;this.points.subpoint.p42.reason=this.tableInfo[0].project[3].data[1].reason;
                    this.points.subpoint.p43.point=this.tableInfo[0].project[3].data[2].score;this.points.subpoint.p43.reason=this.tableInfo[0].project[3].data[2].reason;
                    this.points.subpoint.p44.point=this.tableInfo[0].project[3].data[3].score;this.points.subpoint.p44.reason=this.tableInfo[0].project[3].data[3].reason;

                    this.points.subpoint.p51.point=this.tableInfo[0].project[4].data[0].score;this.points.subpoint.p51.reason=this.tableInfo[0].project[4].data[0].reason;
                    this.points.subpoint.p52.point=this.tableInfo[0].project[4].data[1].score;this.points.subpoint.p52.reason=this.tableInfo[0].project[4].data[1].reason;
                    this.points.subpoint.p53.point=this.tableInfo[0].project[4].data[2].score;this.points.subpoint.p53.reason=this.tableInfo[0].project[4].data[2].reason;
                    this.points.subpoint.p54.point=this.tableInfo[0].project[4].data[3].score;this.points.subpoint.p54.reason=this.tableInfo[0].project[4].data[3].reason;
                    this.points.subpoint.p55.point=this.tableInfo[0].project[4].data[4].score;this.points.subpoint.p55.reason=this.tableInfo[0].project[4].data[4].reason;
                    this.points.subpoint.p56.point=this.tableInfo[0].project[4].data[5].score;this.points.subpoint.p56.reason=this.tableInfo[0].project[4].data[5].reason;
                    //
                    this.points.subpoint.p61.point=this.tableInfo[1].project[0].data[0].score;this.points.subpoint.p61.reason=this.tableInfo[1].project[0].data[0].reason;
                    this.points.subpoint.p62.point=this.tableInfo[1].project[0].data[1].score;this.points.subpoint.p62.reason=this.tableInfo[1].project[0].data[1].reason;
                    this.points.subpoint.p63.point=this.tableInfo[1].project[0].data[2].score;this.points.subpoint.p63.reason=this.tableInfo[1].project[0].data[2].reason;
                    this.points.subpoint.p64.point=this.tableInfo[1].project[0].data[3].score;this.points.subpoint.p64.reason=this.tableInfo[1].project[0].data[3].reason;
                    this.points.subpoint.p65.point=this.tableInfo[1].project[0].data[4].score;this.points.subpoint.p65.reason=this.tableInfo[1].project[0].data[4].reason;
                    this.points.subpoint.p66.point=this.tableInfo[1].project[0].data[5].score;this.points.subpoint.p66.reason=this.tableInfo[1].project[0].data[5].reason;
                    this.points.subpoint.p67.point=this.tableInfo[1].project[0].data[0].score;this.points.subpoint.p67.reason=this.tableInfo[1].project[0].data[6].reason;



                    this.points.subpoint.p11.point=this.tableInfo[0].project[0].data[0].score;this.points.subpoint.p11.reason=this.tableInfo[0].project[0].data[0].reason;
                    this.points.subpoint.p11.point=this.tableInfo[0].project[0].data[0].score;this.points.subpoint.p11.reason=this.tableInfo[0].project[0].data[0].reason;


                    
                   
                    // PointCout:{
                    //     p81:{   //p11---p81  100-
                    //         point:0
                    //     },
                    //     p82:{
                    //         point:0
                    //     },
                    //     p83:{
                    //         pointIn:0,
                    //         point:0
                    //     },
                    //     p84:{
                    //         point:0
                    //     },
                    //     p85:{
                    //         point:0
                    //     }
                    // }
                   
				},
				deep:true
			}
        },
        methods: {
            GetPoint(){
                if(this.createNew){

                }
                else{
                    this.points={}//ajax
                }
            },
            Caculatepoints(){
                let subpoints=0;
                for(var key in this.points.subpoint)
                {
                    subpoints=subpoints+this.points.subpoint[key].point;
                }
                let addpoints=0;
                for(var key in this.points.addpoint)
                {
                    addpoints=addpoints+this.points.addpoint[key].point;
                }
                let foujue=false;

                for(var key in this.points.foujue)
                {
                    if(this.points.foujue[key].iSok=='不合格'){
                        foujue=true
                        break;
                    }
                }
                //计算分数
               this. points.PointCout.p81.point=((100-subpoints+addpoints)*0.7).toFixed(1);
                this.points.PointCout.p83.point=(this.points.PointCout.p83.pointIn*0.1).toFixed(1);
                if(foujue==true){
                    this.points.PointCout.p85.point=0;
                }
                else{
                    this.points.PointCout.p85.point=this.points.PointCout.p81.point+this.points.PointCout.p82.point+this.points.PointCout.p83.point+this.points.PointCout.p84.point;
                }
            },
            FztableInfo(){
                this.tableInfo=[{
                    type: "减分项",
                    project: [{
                            name: "一、带头学习提高，积极参加党内组织生活",  
                            scoreLimit: "25分",
                            data: [{content: "1.党员非因参加公务或处理重大紧急突发事件的，未按时参加三会一课、主题党日、专题组织生活会低于16次的扣3分",type:'input',reason:this.points.subpoint.p11.reason ,score: this.points.subpoint.p11.point},
                                {content: "2.无故不参加各类集中学习、专题讲座、学习座谈会每次扣1分",type:'input',reason:this.points.subpoint.p12.reason ,score: this.points.subpoint.p12.point},
                                {content: "3.没有学习笔记扣2分，学习笔记记录不认真的扣1分",type:'input',reason:this.points.subpoint.p13.reason ,score: this.points.subpoint.p13.point},
                                {content: "4.普通党员全年完成体会文章不少于2篇，党员领导班成员全年完成心得体会或调研报告不少于3篇，党支部书记讲1次党课，未完成者扣2分",type:'input',reason:this.points.subpoint.p14.reason ,score:this.points.subpoint.p14.point}
                            ]
                        },
                        {
                            name: "二、带头争创佳绩，提高服务社会本领",
                            scoreLimit: "25分",
                            data: [{content: "1.组织观念不强，不执行组织决定，不服从工作任务分配的扣2分",type:'input',reason:this.points.subpoint.p21.reason ,score:this.points.subpoint.p21.point},
                                {content: "2.因工作失误给单位、职工利益造成明显损失的，或受到本单位通报批评的，扣2分。",type:'input',reason:this.points.subpoint.p22.reason ,score:this.points.subpoint.p22.point},
                                {content: "3.因工作失误造成项目返工的扣2分",type:'input',reason:this.points.subpoint.p23.reason ,score:this.points.subpoint.p23.point},
                                {content: "4.在工作岗位上不能发挥党中先锋模范作用，职工不满意的，扣2分",type:'input',reason:this.points.subpoint.p24.reason ,score:this.points.subpoint.p24.point},
                                {content: "5.因泄露单位生产资料和技术资料造成损失的，扣2分",type:'input',reason:this.points.subpoint.p25.reason ,score:this.points.subpoint.p25.point},
                                {content: "6.事业单位班子成员（党员）未完成抓党建工作履职清单目标的，扣2分。支部书记、委员未完成抓党建工作履职清单目标的，扣2分。",type:'input',reason:this.points.subpoint.p26.reason ,score:this.points.subpoint.p26.point},
                            ]
                        },
                        {
                            name: "三、带头服务职，构建和谐单位",
                            scoreLimit: "15分",
                            data: [{content: "1.对职工反映的问题，未按照职责分式进行妥善答复和具体落实的，导致矛盾纠纷升级的，每次扣2分。",type:'input',reason:this.points.subpoint.p31.reason ,score:this.points.subpoint.p31.point},
                                {content: "2.全年未参加本单位组织的困难群体求助、慈善捐款、志愿者等社会公益活动的，扣2人。",type:'input',reason:this.points.subpoint.p32.reason ,score:this.points.subpoint.p32.point},
                                {content: "3.单位班子成员（党员）没有完成结对帮扶困难户任务、不参加基层调研慰问的，扣2分",type:'input',reason:this.points.subpoint.p33.reason ,score:this.points.subpoint.p33.point},
                                {content: "4.不团结职工、与职工发生纠纷被认定负主要责任的，每次扣2分。",type:'input',reason:this.points.subpoint.p34.reason ,score:this.points.subpoint.p34.point},
                                {content: "5.其他服务群众工作中出现矛盾和问题的，由支委会酌情扣分",type:'input',reason:this.points.subpoint.p35.reason ,score:this.points.subpoint.p35.point},
                            ]
                        },
                        {
                            name: "四、带头遵纪守法，加强作风建设",
                            scoreLimit: "15分",
                            data: [{content: "1.全年迟到、早退次数较多，干部职工反响强烈的扣3分。",type:'input',reason:this.points.subpoint.p41.reason ,score:this.points.subpoint.p41.point},
                                {content: "2.上班时间炒股、玩游戏、看电影等，每次扣0.5分。",type:'input',reason:this.points.subpoint.p42.reason ,score:this.points.subpoint.p42.point},
                                {content: "3公车私用的，每次扣2分。",type:'input',reason:this.points.subpoint.p42.reason ,score:this.points.subpoint.p42.point},
                                {content: "4.有违反保密规定的，视情节扣2—5分。",type:'input',reason:this.points.subpoint.p43.reason ,score:this.points.subpoint.p43.point},
                            ]
                        },
                        {
                            name: "五、带头弘扬正气，营造良好风尚",
                            scoreLimit: "15分",
                            data: [{content: "1.不尊老爱幼，不遵守居住地社区居民自治公约或社区管理规章制度的，扣2-4分",type:'input',reason:this.points.subpoint.p51.reason ,score:this.points.subpoint.p51.point},
                                {content: "2.在公共场所违背社会公序良俗的不文明行为，造成不良影响的，扣1-3分。",type:'input',reason:this.points.subpoint.p52.reason ,score:this.points.subpoint.p52.point},
                                {content: "3.不能积极团结同事，发生非原则工作争执并造成不良影响的扣2分。",type:'input',reason:this.points.subpoint.p53.reason ,score:this.points.subpoint.p53.point},
                                {content: "4.因本人原因，发生邻里、或者其他纠纷产生恶劣影响的扣2-3分。",type:'input',reason:this.points.subpoint.p54.reason ,score:this.points.subpoint.p54.point},
                                {content: "5.党员领导干部中出现有损职工利益行为造成不良影响的或引发职申诉的，扣2-5分",type:'input',reason:this.points.subpoint.p55.reason ,score:this.points.subpoint.p55.point},
                                {content: "6.不爱护单位公用设施，有破坏行为的，扣2分。",type:'input',reason:this.points.subpoint.p56.reason ,score:this.points.subpoint.p56.point},
                            ]
                        }
                    ]
                },
                {
                    type: "加分项",
                    project: [{
                        name: "加分项目为额外加分，最高不超过10分",
                        scoreLimit: "10分",
                        data: [{content: "1.因工作表现突出，党员个人当年度受单位、上级党组织发文表彰的加1-3分",type:'input',reason:this.points.addpoint.p61.reason ,score:this.points.addpoint.p61.point},
                            {content: "2.向党报党刊投稿并被署名刊发，加1-2分",type:'input',reason:this.points.addpoint.p62.reason ,score:this.points.addpoint.p62.point},
                            {content: "3.向单位提出合理化建议并被告采纳的，每次加1分",type:'input',reason:this.points.addpoint.p63.reason ,score:this.points.addpoint.p63.point},
                            {content: "4.有见义勇为的，每一次加4分，向公安机关或检察机关、纪检监察部门提供线索的，每次加2分。",type:'input',reason:this.points.addpoint.p64.reason ,score:this.points.addpoint.p64.point},
                            {content: "5.主动参加社会公益或志愿者服务的，由支委会酌情加1-3分。",type:'input',reason:this.points.addpoint.p65.reason ,score:this.points.addpoint.p65.point},
                            {content: "6.按时完成组织交办的急难险重的任务的，加1-3分",type:'input',reason:this.points.addpoint.p66.reason ,score:this.points.addpoint.p66.point},
                            {content: "7.兼职党务干部党建工作业绩突出的，加2分。",type:'input',reason:this.points.addpoint.p67.reason ,score:this.points.addpoint.p67.point},
                        ]
                    }]
                    
                },
                {
                    type: "一票否决",
                    project: [{
                        name: "有以下行为之一的，实行一票否决，可直接认定为不合格党员",
                        scoreLimit: "--",
                        data: [{content: "1.因违法违纪行为受到纪检监察、公安、法院等机关处理的。",type:'select',reason:this.points.foujue.p71.reason ,iSok:this.points.foujue.p71.iSok},
                            {content: "2.参加“法轮功“等邪教组织及其他非法组织活动的，经教育仍不改正的。",type:'select',reason:this.points.foujue.p72.reason ,iSok:this.points.foujue.p72.iSok},
                            {content: "3.信仰宗教或参与封建迷信活动，经教育仍不改正的。",type:'select',reason:this.points.foujue.p73.reason ,iSok:this.points.foujue.p73.iSok},
                            {content: "4.无正当理由，连续6个月不交纳党费，不参加党的组织生活，不做党组织所分配工作的。",type:'select',reason:this.points.foujue.p74.reason ,iSok:this.points.foujue.p74.iSok},
                            {content: "5.参与或组织群众非法上访或越级上访的。",type:'select',reason:this.points.foujue.p75.reason ,iSok:this.points.foujue.p75.iSok},
                            {content: "6.在各种公开场合、媒介、网络上发表或转发明显有悖党员政治纪律言论的。",type:'select',reason:this.points.foujue.p76.reason ,iSok:this.points.foujue.p76.iSok},
                        ]
                    }]
                },
                {
                    type: "计分",
                    project: [{
                        name: "日常行为积分",
                        scoreLimit: "100分",
                        data: [{content: "日常行为积分为100分，分为基础项目和加分项目，按照70％比例计入总分",type:'input',reason:'',score:this.points.PointCout.p81.point}]
                    },
                    {
                        name: "个人自评积分",
                        scoreLimit: "10分",
                        data: [{content: "个人自评积分为10分，由党员按照评分标准为自自己打分，交党支总计入最后分值。",type:'input',reason:'',score:this.points.PointCout.p82.point}                               
                        ]
                    },
                    {
                        name: "民主评议积分",
                        scoreLimit: "10分",
                        data: [{content: "民主评议积分为10分，每年年底由全体打分确定，分值为评议均分×10％",type:'input',reason:'',score:this.points.PointCout.p83.point}]
                    },
                    {
                        name: "党组织评定积分",
                        scoreLimit: "10分",
                        data: [{content: "党组织评定积分为10分。每年年底由总支、支委会召开会议集体研究，结合党员的日常表现给予综合评定。",type:'input',reason:'',score:this.points.PointCout.p84.point}]
                    },
                    {
                        name: "党员个人年度总得分",
                        scoreLimit: "100分",
                        data: [{content: "按照“日常行为积＋个人自评积分＋民主评议积分＋党组织评定积分”即为该党员年度总积分",type:'input',reason:'',score:this.points.PointCout.p85.point}]
                    },
                    ]
                }]
            },
            sumProject(arr) {
                let total = 1;
                arr.forEach(e => {
                    total += parseInt(e.data.length + 1);
                });
                return total;
            },
            showreason(data){
                if(this.disabledEdit==true){
                    this.$alert(reason, '提示', {
                        confirmButtonText: '确定',
                    });
                }
                else if(this.disabledEdit==false){
                    this.$prompt('请输入原因', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        inputValue:data.reason
                    }).then(({ value }) => {
                        data.reason=value;
                    }).catch(action => {
                    });
                }
            },
            update(){
                console.log(this.tableInfo);
                console.log(this.points);
                
            },
        }
    };
</script>
<style>
    table.hideInTable {
        margin-top: 15px;
        width: 100%;
        /* border: 1px solid #8a8b8d; */
        border-collapse: collapse;
    }

  .hideInTable  th {
        background-color: #f8f8f9;
    }

   .hideInTable th,
    td {
        text-align: center;
        vertical-align: center;
        line-height: 20px;
    }

   .hideInTable td.content {
        text-align: left;
    }
    .myINput{
        width: auto;
    }
    .myINput input{
        text-align: center;
        
    }
</style>